<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .pic{
            width: 150px;
            height: 150px;
            border: 1px solid #ccc;
            margin: 100px auto;

        }
        .pic img{
            cursor: pointer;
        }
    </style>
</head>
<body>
<div class="pic">
    <img src="img/QQ图片20180115172251.jpg" alt="">
</div>
</body>
</html>
<script src="js/jquery-1.10.1.js"></script>
<script>
    $(function () {
        var time = 600;
        var distance = -20;
        $("img").hover(function () {
            $(this).animate({
                "marginLeft" :distance
            },time)
        },function () {
            $(this).stop(true).animate({
                "marginLeft" : 0
            })
        })
    })
</script>


